﻿using KLS.PPDS.Data.Database.Repository.RepositoryInterfaces;



namespace KLS.PPDS.Data.Database.Repository
{
    public sealed class RepositoryLoader<T>
    {
         T m_Repository;        
 
        public static RepositoryLoader<T> Instance
        {
            get
            {
                return new RepositoryLoader<T>();//Nested.Loader;
            }
        }
       
        // Assists with ensuring thread-safe, lazy singleton
        private class Nested
        {
            internal static readonly RepositoryLoader<T> Loader = new RepositoryLoader<T>();
        }
      
        private RepositoryLoader()
        {
            IRepositoryFactory<T> repositoryFactory = new RepositoryFactory<T>();
            m_Repository = repositoryFactory.GetRepository();            
        }

        public T Repository
        {
            get 
            {
                return m_Repository; 
            }
        }
    }
}
